package net.maku.module.file.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.module.file.convert.BusiFileConvert;
import net.maku.module.file.entity.BusiFileEntity;
import net.maku.module.file.service.BusiFileService;
import net.maku.module.file.vo.BusiFileVO;
import net.maku.newbase.NewBaseController;
import net.maku.newbase.NewQuery;
import net.maku.newbase.PageParam;

import org.springframework.web.bind.annotation.*;

/**
* 业务_文档库
*
* @author 阿沐 babamu@126.com
*/
@RestController
@RequestMapping("nb/file")
@Tag(name="业务_文档库")
@AllArgsConstructor
public class BusiFileController extends NewBaseController<BusiFileService, BusiFileEntity> {

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<BusiFileVO>> page(PageParam page, NewQuery query){
        LambdaQueryWrapper<BusiFileEntity> select = new LambdaQueryWrapper<>();

        IPage<BusiFileEntity> iPage = entityService.page(page.b(), select);
        return Result.ok(new PageResult<>(BusiFileConvert.INSTANCE.convertList(iPage.getRecords()), iPage.getTotal()));
    }

}